#include <public/config.h>
#include <public/uart_dev_putchar.h>
#include <public/basic_types.h>

#define STATUS_REG_OFFSET	0x04
#define DATA_REG_OFFSET	0x00
#define UART_THE	(1 << 2)

void sgi_uart_dev_putchar(uint8_t car)
{
	volatile uint32_t uart_status;

	/*  Waiting for ready data in the a channel */
	while(!((uart_status = SGI_UART_REGISTER(STATUS_REG_OFFSET)) & UART_THE));

	SGI_UART_REGISTER(DATA_REG_OFFSET) = car;

	/*  Wait for the correct character transmision  */
	while(!((uart_status = SGI_UART_REGISTER(STATUS_REG_OFFSET)) & UART_THE));
}

void ssi_uart_dev_putchar(uint8_t car)
{
	volatile uint32_t uart_status;

	/*  Waiting for ready data in the a channel */
	while(!((uart_status = SSI_UART_REGISTER(STATUS_REG_OFFSET)) & UART_THE));

	SSI_UART_REGISTER(DATA_REG_OFFSET) = car;

	/*  Wait for the correct character transmision  */
	while(!((uart_status = SSI_UART_REGISTER(STATUS_REG_OFFSET)) & UART_THE));
}
